home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _2BBB98EE148149768183C28AA4819236 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.4 KB  |  41 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.  
  11.       VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
  12.       Param4f (Name = Bend Comp 'ObjWaveX' Comp 'ObjWaveY' Comp 'Bending' Comp = 1)
  13.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, BEND }
  14.       DeclarationsScript
  15.       {
  16.         IN_T0_C0_TANG
  17.         OUT_T0_T1_T2_C0
  18.       }
  19.       PositionScript = PosBending
  20.       CoreScript
  21.       {
  22.         OUT.Tex0.xy = IN.TexCoord0.xy;
  23.         OUT.Tex1.xy = IN.TexCoord0.xy;
  24.  
  25.         // compute the 3x3 tranform from tangent space to object space
  26.         // store normalized light vector
  27.         float3 lightVec = normalize(LightPos.xyz - vPos.xyz);
  28.         float3 normal = IN.TNormal;
  29.         float fDot = dot(lightVec, normal);
  30.         normal = normal * sign(fDot);
  31.  
  32.         float3x3 objToTangentSpace;
  33.         objToTangentSpace[0] = IN.Tangent;
  34.         objToTangentSpace[1] = IN.Binormal;
  35.         objToTangentSpace[2] = normal;
  36.         
  37.         // transform light vector from object space to tangent space and pass it as a color
  38.         OUT.Tex2.xyz = mul(objToTangentSpace, LightPos.xyz - vPos.xyz);
  39.         OUT.Color = IN.Color;
  40.       }
  41.